// SB_BPA.cpp: implementation of the CSB_BPA class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "../../Include/Swi/SB_BPA.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSB_BPA::CSB_BPA()
{
	m_chType = 'S';
	m_chSubType = 'B';
	m_chChangeCode = ' ';

	m_chISIG = '0';
	m_dTd = 0;
	m_dTw1 = 0;
	m_dTw2 = 0;
	m_dT6 = 0;
	m_dTw3 = 0;
	m_dTw4 = 0;
	m_dT7 = 0;
	m_dKs2 = 0;
	m_dKs3 = 0;
	m_dKpg = 0;
	m_dMva_bse = 0;

	m_strCardType[0] = 'S';
}

CSB_BPA::CSB_BPA(CSB_BPA &sbBPA):CUnit_BPA(sbBPA)
{
	m_chISIG = sbBPA.m_chISIG;
	m_dTd = sbBPA.m_dTd;
	m_dTw1 = sbBPA.m_dTw1;
	m_dTw2 = sbBPA.m_dTw2;
	m_dT6 = sbBPA.m_dT6;
	m_dTw3 = sbBPA.m_dTw3;
	m_dTw4 = sbBPA.m_dTw4;
	m_dT7 = sbBPA.m_dT7;
	m_dKs2 = sbBPA.m_dKs2;
	m_dKs3 = sbBPA.m_dKs3;
	m_dKpg = sbBPA.m_dKpg;
	m_dMva_bse = sbBPA.m_dMva_bse;
}

CSB_BPA::~CSB_BPA()
{

}

bool CSB_BPA::FillEx(char *buffer)
{
	bool bResult = CUnit_BPA::FillEx(buffer);

	if (!bResult)
	{
		printf("Error in (CSB_BPA::FillEx): no basic information!\n");
		return false;
	}

	if (strlen(buffer)<17)
		return true;
	
	m_chISIG = buffer[16];
	if(EndOfSec(&buffer[16],1))
		return true;

	m_dTd = StrToDouble(&buffer[17],5,0);
	if(EndOfSec(&buffer[17],5))
		return true;

	m_dTw1 = StrToDouble(&buffer[22],5,0);
	if(EndOfSec(&buffer[22],5))
		return true;

	m_dTw2 = StrToDouble(&buffer[27],5,0);
	if(EndOfSec(&buffer[27],5))
		return true;

	m_dT6 = StrToDouble(&buffer[32],5,0);
	if(EndOfSec(&buffer[32],5))
		return true;

	m_dTw3 = StrToDouble(&buffer[37],5,0);
	if(EndOfSec(&buffer[37],5))
		return true;

	m_dTw4 = StrToDouble(&buffer[42],5,0);
	if(EndOfSec(&buffer[42],5))
		return true;

	m_dT7 = StrToDouble(&buffer[47],5,0);
	if(EndOfSec(&buffer[47],5))
		return true;

	m_dKs2 = StrToDouble(&buffer[52],5,0);
	if(EndOfSec(&buffer[52],5))
		return true;

	m_dKs3 = StrToDouble(&buffer[57],5,0);
	if(EndOfSec(&buffer[57],5))
		return true;

	m_dKpg = StrToDouble(&buffer[62],5,0);
	if(EndOfSec(&buffer[62],5))
		return true;

	m_dMva_bse = StrToDouble(&buffer[67],5,0);
	if(EndOfSec(&buffer[67],5))
		return true;

	return true;
}

bool CSB_BPA::UpdateEx(char *buffer)
{
	bool bResult = CUnit_BPA::UpdateEx(buffer);

	if (!bResult)
	{
		printf("Error in (CSB_BPA::UpdateEx): impossible!\n");
		return false;
	}

	buffer[16] = m_chISIG;
	DoubleToStr(m_dTd,&buffer[17],5,0);
	DoubleToStr(m_dTw1,&buffer[22],5,0);
	DoubleToStr(m_dTw2,&buffer[27],5,0);
	DoubleToStr(m_dT6,&buffer[32],5,0);
	DoubleToStr(m_dTw3,&buffer[37],5,0);
	DoubleToStr(m_dTw4,&buffer[42],5,0);
	DoubleToStr(m_dT7,&buffer[47],5,0);
	DoubleToStr(m_dKs2,&buffer[52],5,0);
	DoubleToStr(m_dKs3,&buffer[57],5,0);
	DoubleToStr(m_dKpg,&buffer[62],5,0);
	DoubleToStr(m_dMva_bse,&buffer[67],5,0);

	return true;
}